﻿using System;

[Serializable]
public class OnlineAwardsData
{
    public int index;
    public float currentTime;
    public OnlineAwardsState[] states;
    public long dateTime;

    public void Initialize(int []times)
    {
        index = 0;
        currentTime = times[index];
        for(var i=0;i<times.Length;i++)
        {
            states[i] = OnlineAwardsState.None;
        }
        dateTime = TimeHelper.ConvertDateTimeToLong(DateTime.Now);
    }

    public static OnlineAwardsData Load()
    {
        var json = DataHelper.GetString(typeof(OnlineAwardsData).Name);
        return LitJson.JsonMapper.ToObject<OnlineAwardsData>(json);
    }

    public static bool HasKey()
    {
        return DataHelper.HasKey(typeof(OnlineAwardsData).Name);
    }

    public void Save()
    {
        DataHelper.SetString(this.GetType().Name, LitJson.JsonMapper.ToJson(this));
        DataHelper.SaveAll();
    }
}
